package com.yyw.foodie.service.tasks;

import com.yyw.foodie.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author 易煜玮
 * @ClassName OrderCloseTask.java
 * @Description 订单相关任务
 * @createTime 2021年06月03日 22:30:00
 */
@Component
@Slf4j
public class OrderTask {

    @Autowired
    private OrdersService ordersService;

    /**
     * 每隔1天检查一次订单信息
     */
    @Scheduled(cron = "0 0 0 1/1 * ?")
    public void timingOrderClose() {
        log.info("开始检查订单信息，关闭没有支付的订单信息....");
        ordersService.closeOrder();
        log.info("检查未支付的订单信息结束...");
    }
}
